package com.palm.core.data;

import org.noear.solon.annotation.Note;
import org.noear.solon.core.handle.Result;
import org.sagacity.sqltoy.model.Page;

import java.util.List;

/**
 * 分页结果
 * @param <T>
 */
public class PageResult<T> extends Result<List<T>> {
    long total;

    public PageResult(){
        super();
    }

    public PageResult(List<T> data) {
        super(data);
    }

    public PageResult(int code, String description) {
        super(code,description);
    }



    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }
    @Note("成功的结果")
    public static <T> PageResult<T> succeed(Page<T> page) {
        PageResult result= new PageResult<>();
        result.setTotal(page.getRecordCount());
        result.setData(page.getRows());
        return result;
    }
}
